﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PropertyManagement.Core.DataAccess;

namespace PropertyManagement.Core.Model {
    public abstract class AbstractBaseEntity {
        public DateTime CreationDate { get; set; }
        public DateTime LastUpdate { get; set; }
        public int CreationUserID { get; set; }
        public int LastActionUserID { get; set; }
     

        private SystemUser creationUser;
        public  SystemUser CreationUser {
            get {
                if (creationUser == null) {
                    creationUser = SystemUserDataAccess.GetById(CreationUserID);
                }
                return creationUser;
            }
        }

        private SystemUser lastActionUser;
        public  SystemUser LastActionUser {
            get {
                if (lastActionUser == null) {
                    lastActionUser = SystemUserDataAccess.GetById(LastActionUserID);
                }
                return lastActionUser;
            }
        }

        public string LastActionUserName {
            get { return LastActionUser.UserName; }
        }

        public string CreationUserName {
            get { return CreationUser.UserName; }
        }
    }
}
